<?php
/* @var $this CampaignController */
/* @var $model Campaign */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'campaign-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>
	<?php //$level = Yii::app()->request->getParam(level);?>
		<div class="row">
		<?php echo $form->labelEx($model,'campaign_name'); ?>
		<?php echo $form->textField($model,'campaign_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'campaign_name'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'zy_campaign_script'); ?>
		<?php echo $form->textArea($model,'zy_campaign_script',array('size'=>2000,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'zy_campaign_script'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'sales_people'); ?>
		<?php //echo $form->textField($model,'sales_people',array('size'=>60,'maxlength'=>255)); ?>
		<?php //echo $form->dropDownList($model, 'sales_people',User::model()->getSalespeople());?>
		<?php
			$arr = explode('|',$model->sales_people);
			$result = User::model()->getSalespeople();
			$k=0;
			for($i=0; $i<count($result); $i++){
				for($j=0; $j<count($arr); $j++){
					if($arr[$j] == $result[$i]['user_id']){
						$k++;
					?>
					<input type="checkbox"  name="sales_people[]" checked="checked" value="<?php echo $result[$i]['user_id'];?>" /><?php echo $result[$i]['user_name'];?>
					<?php
					}
					
				}
				if(($i+1)%5 == 0&&$i>=4){
						echo '</br >';
					}
				if($k == 0){
				?>
			<input type="checkbox"  name="sales_people[]" value="<?php echo $result[$i]['user_id'];?>" /><?php echo $result[$i]['user_name'];?>	
		<?php
			}
			$k=0;
		}
		?>
		<?php echo $form->error($model,'sales_people'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'zy_potentiel_customers_list_id'); ?>
		<?php //echo $form->textField($model,'zy_potentiel_customers_list_id'); ?>
			<?php
			$arr = explode('|',$model->zy_potentiel_customers_list_id);
			$result = PotentialCustomersList::model()->findAll();
			$k=0;
			for($i=0; $i<count($result); $i++){
				for($j=0; $j<count($arr); $j++){
					if($arr[$j] == $result[$i]['potential_customers_list_id']){
						$k++;
					?>
					<input type="checkbox"  name="zy_potentiel_customers_list_id[]" checked="checked" value="<?php echo $result[$i]['potential_customers_list_id'];?>" /><?php echo $result[$i]['potential_customers_list_name'];?>
					<?php
					}
					
				}
				if(($i+1)%5 == 0&&$i>=4){
						echo '</br >';
					}
				if($k == 0){
				?>
			<input type="checkbox"  name="zy_potentiel_customers_list_id[]" value="<?php echo $result[$i]['potential_customers_list_id'];?>" /><?php echo $result[$i]['potential_customers_list_name'];?>	
		<?php
			}
			$k=0;
		}
		?>
		<?php echo $form->error($model,'zy_potentiel_customers_list_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'zy_campaign_status'); ?>
		<?php //echo $form->textField($model,'zy_campaign_status',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->dropDownList($model,'zy_campaign_status',array('0'=>'开启','1'=>'关闭'));?>
		<?php echo $form->error($model,'zy_campaign_status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->